#include "my.h"
#include <stdlib.h>
void input()
{
	
	printf("请输入用户的id\n");
	
	char idstr[10];
	struct user user1;
	
	//user1.id = 666;;
	//user1.name = "jack";
	
	gets(idstr);
	user1.id = atoi(idstr);
	
	printf("请输入用户的name\n");
	//strcpy(user1.name, "jack");


	//strcpy(user1.name, fgets());
	gets(user1.name);


	//user1.htel = "110";
	//strcpy(user1.htel, "110");
	//user1.tel = "120";
	//strcpy(user1.tel, "120");
	printf("请输入用户的htel");
	gets(user1.htel);
	printf("请输入用户的tel");
	gets(user1.tel);
	printf("%d + %s + %s + %s", user1.id, user1.name, user1.htel, user1.tel);

	FILE * stream;
	stream = fopen("./user.dat", "a");
	//fwrite();
	//fputs("%d %s %s %s", user1.id, user1.name, user1.htel, user1.tel);

	fputs(idstr, stream);
	fputs(" ", stream);
	//char id[10];
	//int numberid = atoi(user.id);
	fputs(user1.name, stream);
	fputs(" ", stream);
	fputs(user1.htel, stream);
	fputs(" ", stream);
	fputs(user1.tel, stream);
	fputs("\n", stream);
	fclose(stream);
}

void output()
{
	printf("test output!\n");
	FILE * stream;
	stream = fopen("./user.dat", "r");
	char buf[1024];
	fread(buf, 1024, 1, stream);

	printf("userid name htel tel\n");
	printf("%s", buf);
	fclose(stream);
}
